package models

import (
	"fmt"
	"github.com/astaxie/beego/orm"
)

//由于model这个名字叫 UserInfo 那么操作的表其实 user_info
type UserInfo struct {
	Id int64
	Uid      string
	Username string
	Password string
	Usertype string
	Regtime  string
	Timestamp string
	Company string
	Department string
	Add string
	Delete string
	Change string
	Querycap string
}


//根据用户名查询用户所在公司
func QueryCompanyByUsername(username string)string {
	o := orm.NewOrm()
	var userrows []UserInfo
	if _, err := o.Raw("SELECT * FROM user_info WHERE username = ?  ", username).QueryRows(&userrows); err != nil {
		fmt.Println("err")
	}
	company := ""
	for _, userrow := range userrows {
		company = userrow.Company
	}
	return company
}
